<template>
	<view class="position-relative" :style="$theme.pageStyle">
		<z-nav-bar backState="2000" ref="navBar" :scrollTop="scrollTop" transparentFixedFontColor="#000"
			type="transparentFixed" title="找律师">
			<view class="preview" slot="center">找律师</view>
		</z-nav-bar>
		<image class="lawyer-bg" src="https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/061713513306nfPh3b.png"
			mode=""></image>
		<view class="customzw" :style="{ height: TopHeight + 'px'}"></view>

		<view class="content_nav" style="padding: 15px;">
			<view style="display: flex;">
				<u-icon name="map" size="16"></u-icon>
				<span style="margin-right: 5px;margin-left: 3px;">
					<sh-address v-model:codeValue="valCode" v-model="val" @change="changeCity"
						@columnchange="columnchange">
						{{city}}
					</sh-address>
				</span>
				<u-icon name="arrow-down" size="12"></u-icon>
			</view>
		</view>

		<view class="authority-lawyer-wrapper">
			<view class="authority-lawyer">
				<view class="head">
					<view class="head-left">
						官方认证律师推荐
					</view>
				</view>
			</view>
			<view class="">
				<block v-for="(item , index) in LocalLawyer" :key="index">
					<view class="local-lawyer-card">
						<view>
							<view class="lawyer">
								<view class="lawyer-left">
									<view class="lawyer-left-info">
										<view class="lawyer-left-info-img">
											<image :src="item.avatar" mode=""></image>
										</view>
									</view>
								</view>
								<view class="lawyer-right">
									<view class="lawyer-name">
										<view class="lawyer-name-content">
											<view class="name-text">{{item.real_name}}</view>
											<view class="position">官方认证</view>
										</view>
									</view>
									<view class="lawyer-right-time-firm">
										<view class="lawyer-right-times">
											执业{{item.year}}年
										</view>
										<view class="lawyer-right-firm">
											{{item.lawoffice}}
										</view>
									</view>
									<view class="lawyer-major-area">
										擅长：{{item.like}}
									</view>
									<view class="lawyer-right-btn-position"
										@click="ToUrl('/pages/lawyer/info?id=' + item.id)">
										<view class="lawyer-right-btn-right">
											<view class="lawyer-right-btn-right-info">
												咨询
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
		
		
		<view class="m-slider">
			<view class="wrap">
				<u-swiper :list="isbanner" height="120" keyName="img" radius="8" indicator indicatorMode="line"
					circular></u-swiper>
			</view>
		</view>
		

		<view class="lawyer_list">
			<block v-for="(item , index ) in DataList" :key="index">
				<view class="law_list recommend-conent" @click="ToUrl('/lawyer/all/info?id=' + item.detailid)">
					<view class="lawyer-list">
						<view class="lawyer home">
							<view class="lawyer-left">
								<view class="lawyer-left-info">
									<view class="lawyer-left-info-img">
										<image :src="item.pic" mode="aspectFill" class="fil"></image>
									</view>
								</view>
							</view>
							<view class="lawyer-right">
								<view class="lawyer-right-name">
									<view class="lawyer-right-name-left">
										{{item.name}}
									</view>
									<view class="lawyer-right-name-right l-color-theme">
										{{item.city ? item.city : item.province}}
									</view>
								</view>
								<view class="lawyer-right-time">

									<view class="lawyer-right-time-right">
										{{item.firm}}
									</view>
									<view class="lawyer-right-time-right">
										{{item.speciality}}
									</view>

								</view>

								<view class="lawyer-right-btn-position">
									<view class="lawyer-right-btn-right">
										<view class="lawyer-right-btn-right-info">
											专业度高
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>

		<view style="height: 40px;"></view>
	</view>
</template>

<script>
	import statusPoint from '@/components/status.vue'
	import $H from '@/common/js/request.js';
	export default {
		components: {
			statusPoint
		},
		data() {
			return {
				city: uni.getStorageSync('city'),
				province: uni.getStorageSync('province'),
				TopHeight: uni.getStorageSync('TopHeight'),
				isLogin: '',
				keyword: "",
				scrollTop: 0,
				indexData: 0,
				navs: [],
				cate: [],
				lawyer: [],
				office: [],
				DataList: [],
				LocalLawyer: [],
				Cate: [],
				isbanner: [],
				limit: 40
			}
		},
		onLoad(opt) {
			this.timeer()
			this.GetLocalLawyer()
			this.Banner()
			if (uni.getStorageSync('token') == '') {
				this.isLogin = 0
			} else {
				this.isLogin = 1
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			this.GetData();
		},
		methods: {
			async Banner() {
				try {
					const res = await $H.post('index/SearchlawyerBanner', {
						
					}, {
						token: true
					});
					this.isbanner = res.data.banenr
				} catch (error) {
					console.error('Error fetching IndexData:', error);
				} finally {
					uni.hideLoading();
				}
			},
			
			async GetLocalLawyer() {
				this.limit = 15;
				var page = this.page + 1;
				try {
					const res = await $H.post('index/locallawyer', {
						'page': page,
						'limit': this.limit,
						'city': this.city
					}, {
						token: true
					});
					var list = res.data.data;
					for (let i = 0; i < list.length; i++) {
						//将数据逐条写入数组
						this.LocalLawyer.push(list[i]);
					}
				} catch (error) {
					console.error('Error fetching IndexData:', error);
				} finally {
					uni.hideLoading();
				}
			},
			changeCity(e) {
				if (e.city === '市辖区') {
					this.province = e.province
					this.timeer();

					return this.city = e.province
				}
				this.city = e.city
				this.province = e.province

				this.DataList = [];
				this.isLoading = false;
				this.scroll = false;
				this.status = 0;
				this.pages = 1;
				this.page = 0;
				this.out = 0;
				this.GetData();
			},
			timeer() {
				this.DataList = [];
				this.isLoading = false;
				this.scroll = false;
				this.status = 0;
				this.pages = 1;
				this.page = 0;
				this.out = 0;
				this.GetData();
			},
			GetData(e) {
				this.out = 0;
				this.isLoading = true;
				this.scroll = false;
				this.limit = 15;
				var page = this.page;
				$H.post('search/searchAllLawyer', {
					'page': page,
					'limit': this.limit,
					'keyword': this.province
				}, {
					token: true
				}).then(res => {
					// console.log(res)
					if (res.code == 1) {
						var list = res.data.list;
						for (let i = 0; i < list.length; i++) {
							//将数据逐条写入数组
							this.DataList.push(list[i]);
						}

						this.page = res.data.start + 40;

					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})



			},
			Tourl(url) {
				uni.navigateTo({
					url: url
				})
			},
			custom(value) {
				this.keyword = value
				this.timeer()
			},
			ToUrl(url){
				uni.navigateTo({
					url: url
				})
			},
			ToCate(item) {
				uni.setStorageSync('S_title_Cate', item.title)
				uni.navigateTo({
					url: '/pages/index/cate?id=' + item.id
				})
			}
		}
	}
</script>

<style>
	page {
		/* background: #fff; */
	}
</style>
<style lang="scss" scoped>
	@import '@/common/css/lawyer.scss';
		
	.fil{
		filter: blur(1.5px);
	}
	.m-slider {
		background: #fff;
		margin: 10px;
		border-radius: 8px;
		border-radius: 8px;
	}
	
	.search {
		margin: 10px;
	}

	.navs {
		margin: 10px;

		.types {
			background: #fff;
			border-radius: 13px;
			margin-top: 13px;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			width: 100%;

			.tyIm {
				display: flex;
				flex-direction: column;
				width: 25%;
				height: 88px;
				justify-content: center;
				align-items: center;
				border-right: 1px solid #f2f3f4;
				border-bottom: 1px solid #f2f3f4;
			}

			.tyIm image {
				width: 35px;
				height: 35px;
			}

			.tyIm text {
				font-size: 13px;
			}
		}
	}


	.authority-lawyer-wrapper {
		background: #fff;
		border-radius: 12px;
		margin: 0 10px;
		padding-bottom: 10px;
	}

	.authority-lawyer,
	.expertise-areas {
		margin: 20px 0 0;
		background: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/111713512831TSkm7i.png') no-repeat;
		background-size: 100% 100px;
		// border-radius: 12px;
		padding: 60px 13px 0;
		box-sizing: border-box;
		position: relative;
	}

	.head {
		display: flex;
		justify-content: space-between;
		line-height: 1;
		align-items: center;
		position: absolute;
		left: 0;
		top: 25px;
	}

	.head .head-left {
		font-family: PingFangSC-Medium;
		font-size: 18px;
		color: #1e1f24;
		line-height: 1;
		font-weight: 700;
		padding-left: 13px;
	}

	.position-relative {
		position: relative;
		z-index: 0;
	}

	.lawyer-bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 390px;
		opacity: 1;
		z-index: -1;
	}



	.lawyer {
		display: flex;
		padding: 16px 13px 10px;
		border-radius: 12px;
		background: #fff;
		position: relative;
		font-family: PingFangSC-Regular;
		margin-top: 9px;
	}

	.lawyer .lawyer-left {
		margin-right: 10px;
	}

	.lawyer .lawyer-left .lawyer-left-info {
		width: 52px;
		height: 52px;
		position: relative;

		image {
			width: 52px;
			height: 52px;
			border-radius: 50%;
		}
	}

	.lawyer .lawyer-right {
		flex: 1;
		min-width: 0;
	}

	.lawyer-name {
		width: 100%;
		font-family: PingFangSC-Regular;
		font-size: 14px;
		font-weight: 700;
		color: #666;
		margin-right: 6px;
		margin-bottom: 7px;
	}

	.lawyer-name .lawyer-name-content {
		color: #1e1f24;
		font-size: 17px;
		font-weight: 700;
		display: flex;
		align-items: center;
	}

	.lawyer-name .name-text {
		line-height: 1;
	}

	.lawyer .lawyer-right .lawyer-right-time-firm {
		width: calc(100% - 19.46vw);
		font-size: 14px;
		line-height: 15px;
		color: #50525c;
		display: flex;
		margin-top: 7px;
		white-space: nowrap;
		min-width: 0;
	}

	.lawyer .lawyer-right .lawyer-right-time-firm .lawyer-right-time {
		margin-right: 8px;
		flex-shrink: 0;
	}

	.lawyer .lawyer-right .lawyer-right-time-firm .lawyer-right-firm {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 14px;
		line-height: 15px;
		color: #50525c;
	}

	.lawyer .lawyer-right .lawyer-major-area {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		color: #50525c;
		margin-top: 8px;
		font-size: 14px;
		line-height: 1;
		width: calc(100% - 19.46vw);
	}

	.lawyer .lawyer-right .lawyer-right-btn-position {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		position: absolute;
		top: 52%;
		right: 13px;
		transform: translateY(-50%);
	}

	.lawyer-name .position {
		display: inline-flex;
		height: 16px;
		padding: 0 4px;
		justify-content: center;
		align-items: center;
		border-radius: 4px;
		border: 1px solid rgba(0, 85, 255, .4);
		box-sizing: border-box;
		color: #05f;
		font-size: 11px;
		margin-left: 6px;
	}

	.lawyer .lawyer-right .lawyer-right-btn-position .lawyer-right-btn-right {
		display: flex;
		font-size: 13px;
		background: rgba(0, 85, 255, .1);
		// width: 68px;
		height: 30px;
		border-radius: 15px;
		align-items: center;
		justify-content: center;
		position: relative;
	}

	.lawyer .lawyer-right .lawyer-right-btn-position .lawyer-right-btn-right .lawyer-right-btn-right-info {
		font-family: PingFangSC-Medium;
		color: #05f;
		font-size: 14px;
		font-weight: 500;
	}

	.lawyer .lawyer-right .lawyer-right-times {
		// width: calc(100% - 188px);
		font-size: 14px;
		line-height: 14px;
		color: #555;
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		margin-right: 10px;
	}
</style>